export default {
  // ------------------------------------------------------------------
  // pragma mark - inti(初始化行为)
  // ------------------------------------------------------------------
  createdInit() {},
  mountedInit() {},
  // ------------------------------------------------------------------
  // pragma mark - Event Response(响应toSearch事件)
  // 命名规范: Name + EventHandler
  // ------------------------------------------------------------------
  // 搜索
  toSearch() {
    this.$emit('searchForm');
    this.$emit('search-click');
  },
  toAdd(){
    this.$emit('add-click');
  },

  toSelect(val, fieldName) {
    this.inputValue[fieldName] = val;
  },
  // 可清空的单选模式下用户点击清空按钮时触发
  clearOption(val, fieldName) {
    this.inputValue[fieldName] = null;
  },
  // 更多操作
  handleCommand(val) {
    this.$emit('btn-click', val);
  },
  // 通过接口改变下拉选项
  visibleChange(status, val) {
    if (status) {
      this.$http.get(val).then(res => {
        if (res.data) {
          this.selectOption = res.data;
        }
      });
    }
  },

  // 单选按钮改变
  selectChange(val) {
    console.log(val, 'select');
    val = val.toString();
  },
  // handleDateInputConfirm(val) {
  //   console.log(val, 'val');
  // },
  toMore(item) {
    this.isShow = !this.isShow;
  },
  // 重置表单
  resetForm(formName) {
    console.log(formName)
    this.$refs[formName].resetFields();
  },
  removeTag(fieldName, event) {
    this.keys.splice(0, 1);
  },
  getType(val) {
    // this.$http.get('api.BaseData.GetType').then(res => {
    //   if (res.data) {
    //     this.tabs = res.data;
    //     this.typeId = this.tabs[0].id;
    //   }
    // });
  },
  toOpen() {
    this.handleClick(100);
    this.typeId = this.activeName;
    this.getType();
  },
  handleClick(tab) {
    // (this.areaCodeDic = []),
    // (this.arsIdDic = []),
    // (this.denomInc = []),
    // // TODO: 代码优化
    // // this.areaCodeDic = this.arsIdDic = this.denomInc = [],

    // (this.typeId = tab.name);
    // this.$http
    //   .post('api.BaseData.QueryProdPlugin', {
    //     typeId: tab.name ? parseInt(tab.name) : 100
    //   })
    //   .then(res => {
    //     if (res.data) {
    //       this.areaCodeDicList = res.data.areaCodeDic;
    //       this.arsIdDicList = res.data.arsIdDic;
    //       this.denomIncList = res.data.denomInc;
    //     }
    //   });
  },
  checkboxHandle(event, fieldName) {
    // this.keys = [];
    // this.checkboxForm = {
    //   areaCodeInc: this.areaCodeDic,
    //   arsIdInc: this.arsIdDic,
    //   denomInc: this.denomInc,
    //   typeId: this.typeId
    // };
    // this.$http
    //   .post('api.BaseData.QueryStdProdIds', this.checkboxForm)
    //   .then(res => {
    //     if (res.data) {
    //       var values = [];
    //       for (var key in res.data) {
    //         values.push(res.data[key]);
    //         this.keys.push(parseInt(key));
    //       }
    //       this.SelectdropDown = values;
    //       this.inputValue[fieldName] = this.keys;
    //     }
    //   });
  },

  cascaderData(value, url) {
    if (value) {
      this.$http.get(url).then(res => {
        if (res.data) {
          this.brandModelList = res.data;
        }
      });
    }
  }
};
